public class Demo9 {
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
           while(! Thread.interrupted()){
               System.out.println("hello");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
                   try {
                       System.out.println(Thread.interrupted());
                       Thread.sleep(2500);
                       System.out.println("dasd");
                   } catch (InterruptedException ex) {
                       ex.printStackTrace();
                   }
//                   break;
               }
           }
        });
        thread.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        thread.interrupt();
    }
}
